package com.boolib.http.core.defaults;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;


/**
 * 作为可重复读ServletInputStream的包装类
 */
public class DefaultReusableStream  extends ServletInputStream {

    private InputStream inputStream;

    public DefaultReusableStream(byte[] bytes) {
        this.inputStream =  new ByteArrayInputStream(bytes);
    }

    public DefaultReusableStream(InputStream inputStream) {
        this.inputStream = inputStream;
    }



    @Override
    public boolean isFinished() {
        return false;
    }

    @Override
    public boolean isReady() {
        return false;
    }

    @Override
    public void setReadListener(ReadListener readListener) {

    }

    @Override
    public int read() throws IOException {
        return this.inputStream.read();
    }
}
